﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Shapes;

namespace FizzGame
{
    
    class Object
    {
        public struct Postion
        {
            public int X;
            public int Y;
        };
        public struct Size
        {
            public int Width;
            public int Height;
        };

        public Object(int X,int Y,int Width,int Height)
        {
            Pos.X = X;
            Pos.Y = Y;
            size.Width = Width;
            size.Height = Height;
            Rect.Width = Width;
            Rect.Height = Height;
        }
        public Object()
        {
        }   

        enum TouchType {ALL,Top,Bottom,Left,Right}

        public Postion Pos;
        public Size size;
        public Rectangle Rect;
        public int HP;

        public bool IsRunning = false;
        public bool IsBack = false;
        public bool IsJump = false;
        public bool IsGround = false;
        public bool IsDown = false;
        public bool IsAttack = false;
        public bool IsHurt = false;

        public bool TouchDetect(Object Another,int type = 0)//0=TouchAll ,
        {
            //
            int Top = Pos.Y - Another.size.Height;
            int Bottom = Pos.Y + size.Height;
            int Right = Pos.X + size.Width;
            int Left = Pos.X - Another.size.Width;
       
                switch (type)
                {
                    case 0:
                        if (Right > Another.Pos.X && Left < Another.Pos.X)
                        {
                            if (Top < Another.Pos.Y && Bottom > Another.Pos.Y)
                                return true;
                        }
                        break;
                    case 1:
                        if (Right-5 > Another.Pos.X && Left+5 < Another.Pos.X)
                        {
                            if (Top-8 < Another.Pos.Y && Top+12 > Another.Pos.Y)
                                return true;
                        }
                        break;
                    case 2:
                        if (Right-5 > Another.Pos.X && Left+5 < Another.Pos.X)
                        {
                            if (Bottom-8 < Another.Pos.Y && Bottom+12 > Another.Pos.Y)
                                return true;
                        }
                        break;
                    case 3:
                        if (Top+5 < Another.Pos.Y && Bottom-5 > Another.Pos.Y)
                        {
                                if (Right+6 > Another.Pos.X && Right-6 < Another.Pos.X)
                                return true;
                        }
                        break;
                    case 4:
                        if (Top+5 < Another.Pos.Y && Bottom-5> Another.Pos.Y)
                        {
                                if (Left+6 > Another.Pos.X && Left-6 < Another.Pos.X)
                                return true;
                        }
                        break;
                    default:
                        return false;
                }
                
            return false;
        }
        public bool EdgeDetect()
        {
            if (Pos.X > (1360-size.Width) || Pos.X < 5 || Pos.Y > (760-size.Height) || Pos.Y < 5)
                return true;
            else return false;
        }

    }
}
